//
//  CTLogic.m
//  ConstellationTalk_0.1
//
//  Created by riley on 15/6/15.
//  Copyright (c) 2015年 riley chu. All rights reserved.
//

#import "CTLogic.h"
#import "CTDebugManager.h"
#import "CTRequestUtil.h"
#import "CTRequestErrorCode.h"
#import "CTUrl.h"
#import "CTFile.h"
#import "CTRequestFlip.h"

@implementation CTLogic

- (void)dealloc
{
    [CTDebugManager showDebugLogInfo:@"dealloc : CTLogic Is Removed!!!"];
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        
    }
    return self;
}

#pragma mark - request -

-(void)followPersonRequest:(CTRequestFollowPseronItem *)item
  successCompletionHandler:(requestSuccessBlock)successBlock
             failedHandler:(requestFailedBlock)failedBlock
{
    NSMutableDictionary * param = [NSMutableDictionary dictionaryWithCapacity:0];
    @try {
        [param setObject:item.token forKey:@"token"];
        [param setObject:item.lang forKey:@"lang"];
        [param setObject:item.uid forKey:@"uid"];
        
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"组装关注某人数据错误！"];
    }
    
    
    [CTRequestUtil sendAsyPostRequest:CT_URL_OTHER_FOLLOW_PERSON(version) withParam:param withCompletionSuccessHandler:^(NSData *data) {
        BOOL isParserSuccess = [self parserFollowPersonData:data];
        if (isParserSuccess == YES) {
            successBlock();
        }
        else
        {
            failedBlock();
        }
    } withFailedHandler:^(NSError *error) {
        failedBlock();
    }];
}

-(void)cancelFollowPersonRequest:(CTRequestCancelFollowPseronItem *)item
        successCompletionHandler:(requestSuccessBlock)successBlock
                   failedHandler:(requestFailedBlock)failedBlock
{
    NSMutableDictionary * param = [NSMutableDictionary dictionaryWithCapacity:0];
    @try {
        [param setObject:item.token forKey:@"token"];
        [param setObject:item.lang forKey:@"lang"];
        [param setObject:item.uid forKey:@"uid"];
        
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"组装取消关注某人数据错误！"];
    }
    
    
    [CTRequestUtil sendAsyPostRequest:CT_URL_OTHER_CANCEL_FOLLOW_PERSON(version) withParam:param withCompletionSuccessHandler:^(NSData *data) {
        BOOL isParserSuccess = [self parserCancelFollowPersonData:data];
        if (isParserSuccess == YES) {
            successBlock();
        }
        else
        {
            failedBlock();
        }
    } withFailedHandler:^(NSError *error) {
        failedBlock();
    }];
}





-(void)likePersonRequest:(CTRequestLikePseronItem *)item
successCompletionHandler:(requestSuccessBlock)successBlock
           failedHandler:(requestFailedBlock)failedBlock
{
    NSMutableDictionary * param = [NSMutableDictionary dictionaryWithCapacity:0];
    @try {
        [param setObject:item.token forKey:@"token"];
        [param setObject:item.scheme_id forKey:@"scheme_id"];
        
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"组装点赞数据错误！"];
    }
    
    
    [CTRequestUtil sendAsyPostRequest:CT_URL_OTHER_LIKE_CONTENT(version) withParam:param withCompletionSuccessHandler:^(NSData *data) {
        BOOL isParserSuccess = [self parserLikePersonData:data];
        if (isParserSuccess == YES) {
            successBlock();
        }
        else
        {
            failedBlock();
        }
    } withFailedHandler:^(NSError *error) {
        failedBlock();
    }];
}

-(void)cancelLikePersonRequest:(CTRequestCancelLikePseronItem *)item
      successCompletionHandler:(requestSuccessBlock)successBlock
                 failedHandler:(requestFailedBlock)failedBlock
{
    NSMutableDictionary * param = [NSMutableDictionary dictionaryWithCapacity:0];
    @try {
        [param setObject:item.token forKey:@"token"];
        [param setObject:item.scheme_id forKey:@"scheme_id"];
        
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"组装取消点赞数据错误！"];
    }
    
    
    [CTRequestUtil sendAsyPostRequest:CT_URL_OTHER_CANCEL_LIKE_CONTENT(version) withParam:param withCompletionSuccessHandler:^(NSData *data) {
        BOOL isParserSuccess = [self parserCancelLikePersonData:data];
        if (isParserSuccess == YES) {
            successBlock();
        }
        else
        {
            failedBlock();
        }
    } withFailedHandler:^(NSError *error) {
        failedBlock();
    }];
}





-(void)commentRequest:(CTRequestCommentItem *)item
successCompletionHandler:(requestSuccessBlock)successBlock
        failedHandler:(requestFailedBlock)failedBlock
{
    NSMutableDictionary * param = [NSMutableDictionary dictionaryWithCapacity:0];
    @try {
        [param setObject:item.token forKey:@"token"];
        [param setObject:item.scheme_id forKey:@"scheme_id"];
        [param setObject:item.text forKey:@"text"];
        [param setObject:item.lang forKey:@"lang"];
        
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"组装评论某内容数据错误！"];
    }
    
    
    [CTRequestUtil sendAsyPostRequest:CT_URL_OTHER_ADD_COMMENT(version) withParam:param withCompletionSuccessHandler:^(NSData *data) {
        BOOL isParserSuccess = [self parserCommentData:data];
        if (isParserSuccess == YES) {
            successBlock();
        }
        else
        {
            failedBlock();
        }
    } withFailedHandler:^(NSError *error) {
        failedBlock();
    }];
}

-(void)cancelCommentRequest:(CTRequestCancelCommentItem *)item
   successCompletionHandler:(requestSuccessBlock)successBlock
              failedHandler:(requestFailedBlock)failedBlock
{
    NSMutableDictionary * param = [NSMutableDictionary dictionaryWithCapacity:0];
    @try {
        [param setObject:item.token forKey:@"token"];
        [param setObject:item.comment_id forKey:@"comment_id"];
        
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"组装删除自己评论某内容数据错误！"];
    }
    
    
    [CTRequestUtil sendAsyPostRequest:CT_URL_OTHER_DELETE_COMMENT(version) withParam:param withCompletionSuccessHandler:^(NSData *data) {
        BOOL isParserSuccess = [self parserCancelCommentData:data];
        if (isParserSuccess == YES) {
            successBlock();
        }
        else
        {
            failedBlock();
        }
    } withFailedHandler:^(NSError *error) {
        failedBlock();
    }];
}


-(void)commentListRequest:(CTRequestCommentListItems *)item
 successCompletionHandler:(requestSuccessBlock)successBlock
            failedHandler:(requestFailedBlock)failedBlock
{
    NSMutableDictionary * param = [NSMutableDictionary dictionaryWithCapacity:0];
    @try {
        [param setObject:item.token forKey:@"token"];
        [param setObject:item.scheme_id forKey:@"scheme_id"];
        [param setObject:item.count forKey:@"count"];
        [param setObject:item.lang forKey:@"lang"];
        [param setObject:item.page forKey:@"page"];
        [param setObject:item.timelimit forKey:@"timelimit"];
        
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"组装评论列表数据错误！"];
    }
    
    
    [CTRequestUtil sendAsyGetRequest:CT_URL_OTHER_COMMENT_LIST(version) withParam:param withCompletionSuccessHandler:^(NSData *data) {
        BOOL isParserSuccess = [self parserCommectListData:data];
        if (isParserSuccess == YES) {
            successBlock();
        }
        else
        {
            failedBlock();
        }
    } withFailedHandler:^(NSError *error) {
        failedBlock();
    }];
}



-(void)reportRequest:(CTRequestReportItem *)item
successCompletionHandler:(requestSuccessBlock)successBlock
       failedHandler:(requestFailedBlock)failedBlock
{
    NSMutableDictionary * param = [NSMutableDictionary dictionaryWithCapacity:0];
    @try {
        [param setObject:item.token forKey:@"token"];
        [param setObject:item.scheme_id forKey:@"scheme_id"];
        
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"组装举报数据错误！"];
    }
    
    
    [CTRequestUtil sendAsyPostRequest:CT_URL_OTHER_REPORT(version) withParam:param withCompletionSuccessHandler:^(NSData *data) {
        BOOL isParserSuccess = [self parserReportData:data];
        if (isParserSuccess == YES) {
            successBlock();
        }
        else
        {
            failedBlock();
        }
    } withFailedHandler:^(NSError *error) {
        failedBlock();
    }];
}



-(void)deletePublishRequest:(CTRequestDeletePublishItem *)item
   successCompletionHandler:(requestSuccessBlock)successBlock
              failedHandler:(requestFailedBlock)failedBlock
{
    NSMutableDictionary * param = [NSMutableDictionary dictionaryWithCapacity:0];
    @try {
        [param setObject:item.token forKey:@"token"];
        [param setObject:item.scheme_id forKey:@"scheme_id"];
        
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"组装删除发布内容数据错误！"];
    }
    
    
    [CTRequestUtil sendAsyPostRequest:CT_URL_OTHER_DELETE_PUBLISH(version) withParam:param withCompletionSuccessHandler:^(NSData *data) {
        BOOL isParserSuccess = [self parserDeletePublishData:data];
        if (isParserSuccess == YES) {
            successBlock();
        }
        else
        {
            failedBlock();
        }
    } withFailedHandler:^(NSError *error) {
        failedBlock();
    }];
}



-(void)getPublishDetailsInfoRequest:(CTRequestPublishDetailsInfoItem *)item
           successCompletionHandler:(requestSuccessBlock)successBlock
                      failedHandler:(requestFailedBlock)failedBlock
{
    NSMutableDictionary * param = [NSMutableDictionary dictionaryWithCapacity:0];
    @try {
        [param setObject:item.token forKey:@"token"];
        [param setObject:item.scheme_id forKey:@"scheme_id"];
        [param setObject:item.like_num forKey:@"like_num"];
        [param setObject:item.comment_num forKey:@"comment_num"];
        [param setObject:item.visitor forKey:@"visitor"];
        [param setObject:item.lang forKey:@"lang"];
        
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"组装发布内容详情数据错误！"];
    }
   
    [CTRequestUtil sendAsyGetRequest:CT_URL_USERS_PUBLISH_INFO_DETAILS(version) withParam:param withCompletionSuccessHandler:^(NSData *data) {
        BOOL isParserSuccess = [self parserPublishDetailsInfoData:data];
        if (isParserSuccess == YES) {
            successBlock();
        }
        else
        {
            failedBlock();
        }
    } withFailedHandler:^(NSError *error) {
        failedBlock();
    }];
}



-(void)auditStatusRequest:(NSString *)version
 successCompletionHandler:(requestSuccessBlock)successBlock
            failedHandler:(requestFailedBlock)failedBlock
{
    
   
    NSMutableDictionary * param = [NSMutableDictionary dictionaryWithCapacity:0];
    @try {
        
        [param setObject:version forKey:@"name"];
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"组装发布内容详情数据错误！"];
    }
    
    
    [CTRequestUtil sendAsyGetRequest:CT_URL_SWITCH withParam:param withCompletionSuccessHandler:^(NSData *data) {
        BOOL isParserSuccess = [self parserSwitchData:data];
        if (isParserSuccess == YES) {
            successBlock();
        }
        else
        {
            failedBlock();
        }
    } withFailedHandler:^(NSError *error) {
        failedBlock();
    }];
}


#pragma mark - parser data -



-(BOOL)parserFollowPersonData:(NSData *)resultData
{
    
    
    BOOL isParserSuccess = NO;
    
    @try {
        
        NSError * error;
        
        id jsonObject = [NSJSONSerialization
                         JSONObjectWithData:resultData
                         options:NSJSONReadingAllowFragments
                         error:&error];
        if (jsonObject != nil && error == nil){
            if ([jsonObject isKindOfClass:[NSDictionary class]]){
                
                NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
                
                NSString * errCode = [NSString stringWithFormat:@"%@",(NSString *)[deserializedDictionary objectForKey:@"error_code"]];
                if ([errCode isEqualToString:@"0"]) {
                    
                    isParserSuccess = YES;
                    
        
                }
                else{
                    NSString * errDescription = [CTRequestErrorCode errDescription:errCode];
                    [CTDebugManager showErrorLogInfo:errDescription];
                }
            }
        }
        else
        {
            [CTDebugManager showErrorLogInfo:@"解析关注数据错误！"];
        }
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"解析关注数据错误！"];
    }
    
    return isParserSuccess;
}

-(BOOL)parserCancelFollowPersonData:(NSData *)resultData
{
    BOOL isParserSuccess = NO;
    
    @try {
        
        NSError * error;
        
        id jsonObject = [NSJSONSerialization
                         JSONObjectWithData:resultData
                         options:NSJSONReadingAllowFragments
                         error:&error];
        if (jsonObject != nil && error == nil){
            if ([jsonObject isKindOfClass:[NSDictionary class]]){
                
                NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
                
                NSString * errCode = [NSString stringWithFormat:@"%@",(NSString *)[deserializedDictionary objectForKey:@"error_code"]];
                if ([errCode isEqualToString:@"0"]) {
                    
                    isParserSuccess = YES;
                    
                }
                else{
                    NSString * errDescription = [CTRequestErrorCode errDescription:errCode];
                    [CTDebugManager showErrorLogInfo:errDescription];
                }
            }
        }
        else
        {
            [CTDebugManager showErrorLogInfo:@"解析取消关注数据错误！"];
        }
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"解析取消关注数据错误！"];
    }
    
    return isParserSuccess;
}




-(BOOL)parserLikePersonData:(NSData *)resultData
{
    BOOL isParserSuccess = NO;
    
    @try {
        
        NSError * error;
        
        id jsonObject = [NSJSONSerialization
                         JSONObjectWithData:resultData
                         options:NSJSONReadingAllowFragments
                         error:&error];
        if (jsonObject != nil && error == nil){
            if ([jsonObject isKindOfClass:[NSDictionary class]]){
                
                NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
                
                NSString * errCode = [NSString stringWithFormat:@"%@",(NSString *)[deserializedDictionary objectForKey:@"error_code"]];
             
                if ([errCode isEqualToString:@"0"]) {
                    
                    isParserSuccess = YES;
                    
                    
                }
                else{
                    NSString * errDescription = [CTRequestErrorCode errDescription:errCode];
                    [CTDebugManager showErrorLogInfo:errDescription];
                }
            }
        }
        else
        {
            [CTDebugManager showErrorLogInfo:@"解析点赞数据错误！"];
        }
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"解析点赞数据错误！"];
    }
    
    return isParserSuccess;
}


-(BOOL)parserCancelLikePersonData:(NSData *)resultData
{
    BOOL isParserSuccess = NO;
    
    @try {
        
        NSError * error;
        
        id jsonObject = [NSJSONSerialization
                         JSONObjectWithData:resultData
                         options:NSJSONReadingAllowFragments
                         error:&error];
        if (jsonObject != nil && error == nil){
            if ([jsonObject isKindOfClass:[NSDictionary class]]){
                
                NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
                
                NSString * errCode = [NSString stringWithFormat:@"%@",(NSString *)[deserializedDictionary objectForKey:@"error_code"]];
                if ([errCode isEqualToString:@"0"]) {
                    
                    isParserSuccess = YES;
                    
                    
                }
                else{
                    NSString * errDescription = [CTRequestErrorCode errDescription:errCode];
                    [CTDebugManager showErrorLogInfo:errDescription];
                }
            }
        }
        else
        {
            [CTDebugManager showErrorLogInfo:@"解析取消点赞数据错误！"];
        }
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"解析取消点赞数据错误！"];
    }
    
    return isParserSuccess;
}

-(BOOL)parserCommentData:(NSData *)resultData
{
    BOOL isParserSuccess = NO;
    
    @try {
        
        NSError * error;
        
        id jsonObject = [NSJSONSerialization
                         JSONObjectWithData:resultData
                         options:NSJSONReadingAllowFragments
                         error:&error];
        if (jsonObject != nil && error == nil){
            if ([jsonObject isKindOfClass:[NSDictionary class]]){
                
                NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
                
                NSString * errCode = [NSString stringWithFormat:@"%@",(NSString *)[deserializedDictionary objectForKey:@"error_code"]];
                if ([errCode isEqualToString:@"0"]) {
                    
                    isParserSuccess = YES;
                    
                    
                }
                else{
                    NSString * errDescription = [CTRequestErrorCode errDescription:errCode];
                    [CTDebugManager showErrorLogInfo:errDescription];
                }
            }
        }
        else
        {
            [CTDebugManager showErrorLogInfo:@"解析评论数据错误！"];
        }
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"解析评论数据错误！"];
    }
    
    return isParserSuccess;
}

-(BOOL)parserCancelCommentData:(NSData *)resultData
{
    BOOL isParserSuccess = NO;
    
    @try {
        
        NSError * error;
        
        id jsonObject = [NSJSONSerialization
                         JSONObjectWithData:resultData
                         options:NSJSONReadingAllowFragments
                         error:&error];
        if (jsonObject != nil && error == nil){
            if ([jsonObject isKindOfClass:[NSDictionary class]]){
                
                NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
                
                NSString * errCode = [NSString stringWithFormat:@"%@",(NSString *)[deserializedDictionary objectForKey:@"error_code"]];
                if ([errCode isEqualToString:@"0"]) {
                    
                    isParserSuccess = YES;
                    
                    
                }
                else{
                    NSString * errDescription = [CTRequestErrorCode errDescription:errCode];
                    [CTDebugManager showErrorLogInfo:errDescription];
                }
            }
        }
        else
        {
            [CTDebugManager showErrorLogInfo:@"解析删除评论数据错误！"];
        }
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"解析删除评论数据错误！"];
    }
    
    return isParserSuccess;
}


-(BOOL)parserCommectListData:(NSData *)resultData
{
    BOOL isParserSuccess = NO;
    
    @try {
        
        NSError * error;
        
        id jsonObject = [NSJSONSerialization
                         JSONObjectWithData:resultData
                         options:NSJSONReadingAllowFragments
                         error:&error];
        if (jsonObject != nil && error == nil){
            if ([jsonObject isKindOfClass:[NSDictionary class]]){
                
                NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
                
                NSString * errCode = [NSString stringWithFormat:@"%@",(NSString *)[deserializedDictionary objectForKey:@"error_code"]];
                if ([errCode isEqualToString:@"0"]) {
                    
                    isParserSuccess = YES;
                    NSDictionary * infoDic = [deserializedDictionary objectForKey:@"info"];
                    
                    //存档
                    [CTFile cacheDicFile:[infoDic mutableCopy] fileName:@"commentList.plist" saveDoc:CTFileDocLibrary savePath:@"cacheData/other"];
                   
                }
                else{
                    NSString * errDescription = [CTRequestErrorCode errDescription:errCode];
                    [CTDebugManager showErrorLogInfo:errDescription];
                }
            }
        }
        else
        {
            [CTDebugManager showErrorLogInfo:@"解析评论列表数据错误！"];
        }
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"解析评论列表数据错误！"];
    }
    
    return isParserSuccess;
}


-(BOOL)parserReportData:(NSData *)resultData
{
    BOOL isParserSuccess = NO;
    
    @try {
        
        NSError * error;
        
        id jsonObject = [NSJSONSerialization
                         JSONObjectWithData:resultData
                         options:NSJSONReadingAllowFragments
                         error:&error];
        if (jsonObject != nil && error == nil){
            if ([jsonObject isKindOfClass:[NSDictionary class]]){
                
                NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
                
                NSString * errCode = [NSString stringWithFormat:@"%@",(NSString *)[deserializedDictionary objectForKey:@"error_code"]];
                if ([errCode isEqualToString:@"0"]) {
                    
                    isParserSuccess = YES;
                    
                    
                }
                else{
                    
                    NSString * errDescription = [CTRequestErrorCode errDescription:errCode];
                    [CTDebugManager showErrorLogInfo:errDescription];
                }
            }
        }
        else
        {
            [CTDebugManager showErrorLogInfo:@"解析举报数据错误！"];
        }
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"解析举报数据错误！"];
    }
    
    return isParserSuccess;
}



-(BOOL)parserDeletePublishData:(NSData *)resultData
{
    BOOL isParserSuccess = NO;
    
    @try {
        
        NSError * error;
        
        id jsonObject = [NSJSONSerialization
                         JSONObjectWithData:resultData
                         options:NSJSONReadingAllowFragments
                         error:&error];
        if (jsonObject != nil && error == nil){
            if ([jsonObject isKindOfClass:[NSDictionary class]]){
                
                NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
                
                NSString * errCode = [NSString stringWithFormat:@"%@",(NSString *)[deserializedDictionary objectForKey:@"error_code"]];
                if ([errCode isEqualToString:@"0"]) {
                    
                    isParserSuccess = YES;
                    
                    
                }
                else{
                    NSString * errDescription = [CTRequestErrorCode errDescription:errCode];
                    [CTDebugManager showErrorLogInfo:errDescription];
                }
            }
        }
        else
        {
            [CTDebugManager showErrorLogInfo:@"解析删除发布数据错误！"];
        }
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"解析删除发布数据错误！"];
    }
    
    return isParserSuccess;
}



-(BOOL)parserPublishDetailsInfoData:(NSData *)resultData
{
    BOOL isParserSuccess = NO;
    
    @try {
        
        NSError * error;
        
        id jsonObject = [NSJSONSerialization
                         JSONObjectWithData:resultData
                         options:NSJSONReadingAllowFragments
                         error:&error];
        if (jsonObject != nil && error == nil){
            if ([jsonObject isKindOfClass:[NSDictionary class]]){
                
                NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
                
                NSString * errCode = [NSString stringWithFormat:@"%@",(NSString *)[deserializedDictionary objectForKey:@"error_code"]];
                if ([errCode isEqualToString:@"0"]) {
                    
                    isParserSuccess = YES;
                    NSDictionary * infoDic = [deserializedDictionary objectForKey:@"info"];
                    //存档
                    [CTFile cacheDicFile:[infoDic mutableCopy] fileName:@"userPublishDetailInfoList.plist" saveDoc:CTFileDocLibrary savePath:@"cacheData/user"];
                }
                else{
                    NSString * errDescription = [CTRequestErrorCode errDescription:errCode];
                    [CTDebugManager showErrorLogInfo:errDescription];
                }
            }
        }
        else
        {
            [CTDebugManager showErrorLogInfo:@"解析发布详情数据错误！"];
        }
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"解析发布详情数据错误！"];
    }
    
    return isParserSuccess;
}





-(BOOL)parserSwitchData:(NSData *)resultData
{
    BOOL isParserSuccess = NO;
    
    @try {
        
        NSError * error;
        
        id jsonObject = [NSJSONSerialization
                         JSONObjectWithData:resultData
                         options:NSJSONReadingAllowFragments
                         error:&error];
        if (jsonObject != nil && error == nil){
            if ([jsonObject isKindOfClass:[NSDictionary class]]){
                
                NSDictionary *deserializedDictionary = (NSDictionary *)jsonObject;
              
                NSString * errCode = [NSString stringWithFormat:@"%@",(NSString *)[deserializedDictionary objectForKey:@"error_code"]];
                if ([errCode isEqualToString:@"0"]) {
                    
                    isParserSuccess = YES;
                    NSDictionary * infoDic = [deserializedDictionary objectForKey:@"info"];
                    
                    NSString * onLineStr = [NSString stringWithFormat:@"%@",[infoDic objectForKey:@"online_status"]];
                    
                    //存档
                    [CTFile cacheFile:onLineStr fileName:@"switch.text" saveDoc:CTFileDocDocuments savePath:@"switch"];
                   
                }
                else{
                    NSString * errDescription = [CTRequestErrorCode errDescription:errCode];
                    [CTDebugManager showErrorLogInfo:errDescription];
                }
            }
        }
        else
        {
            [CTDebugManager showErrorLogInfo:@"解析审核数据错误！"];
        }
    }
    @catch (NSException *exception) {
        [CTDebugManager showErrorLogInfo:@"解析审核数据错误！"];
    }
    
    return isParserSuccess;
}

@end
